package edu.xja.service.impl;

import edu.xja.dao.TMemberAddressDao;
import edu.xja.entity.TMemberAddress;
import edu.xja.service.TMemberAddressService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TMemberAddress)表服务实现类
 *
 * @author makejava
 * @since 2020-11-18 20:54:31
 */
@Service("tMemberAddressService")
public class TMemberAddressServiceImpl implements TMemberAddressService {
    @Resource
    private TMemberAddressDao tMemberAddressDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TMemberAddress queryById(Integer id) {
        return this.tMemberAddressDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TMemberAddress> queryAllByLimit(int offset, int limit) {
        return this.tMemberAddressDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tMemberAddress 实例对象
     * @return 实例对象
     */
    @Override
    public TMemberAddress insert(TMemberAddress tMemberAddress) {
        this.tMemberAddressDao.insert(tMemberAddress);
        return tMemberAddress;
    }

    /**
     * 修改数据
     *
     * @param tMemberAddress 实例对象
     * @return 实例对象
     */
    @Override
    public TMemberAddress update(TMemberAddress tMemberAddress) {
        this.tMemberAddressDao.update(tMemberAddress);
        return this.queryById(tMemberAddress.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.tMemberAddressDao.deleteById(id) > 0;
    }
}